/**
 * Created by 李宇寒
 * Description:
 * 2019/7/9 0009 下午 10:55.
 */
public class BubbleSort {

    public static int []sort(int a[]){

        for(int i = 0; i < a.length; i++){
            for(int j = 0; j < a.length-i-1; j++){
                int temp;
                if(a[j] > a[j+1]) {
                    temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
            }
        }
        return a;
    }

    public static void main(String []args){
        int a[] = {7,5,1,4,9,2,8};
        int b[] = sort(a);
        for(int i = 0; i<b.length;i++){
            System.out.print(b[i]+",");
        }
    }
}
